package chapter02;

import java.util.Scanner;

public class ShopingMarket {
    public static void main(String[] args) {
        double yaShua = 8.8;
        double maoJng = 10.0;
        double ShuiBei = 18.8;
        double pingGuo = 12.5;
        double xiangJiao = 15.5;
        System.out.println("-----------黑马小商城-----------");
        System.out.println("1.牙刷的价格为：8.8元");
        System.out.println("2.毛巾的价格为：10.0元");
        System.out.println("3.水杯的价格为：18.8元");
        System.out.println("4.苹果的价格为：12.5元");
        System.out.println("5.香蕉的价格为15.5元");

        //循环开始前准备工作
        String xuanZe = "Y";//一种数据类型 存放字符串 默认选购
        double zongJia = 0;//总价一般放在循环外部
        Scanner scl = new Scanner(System.in);//用来获取输入
        //不知道用户循环几次 可能无限次 使用while或者do while
        while (xuanZe.equals("Y")) {//sting不支持xuanZe=="y"
            System.out.println("请输入你需要购买的序列号");
            int xuHao = scl.nextInt();//获取输入的序列号
            //判断用户输入的序列号 进行不同的计算
            if (xuHao == 1) {
                System.out.println("请输入你要购买牙刷的数量");
                int yaShuaShuLiang = scl.nextInt();
                //
                zongJia = zongJia + yaShua * yaShuaShuLiang;
                System.out.println("你买了牙刷" + yaShuaShuLiang + "只，需要花费" + yaShua * yaShuaShuLiang + "元");

            } else if (xuHao == 2) {
                System.out.println("请输入你要购买毛巾的数量");
                int maoJinShuLiang = scl.nextInt();
                //
                zongJia = zongJia + maoJng * maoJinShuLiang;
                System.out.println("你买了毛巾" + maoJinShuLiang + "只，需要花费" + maoJng * maoJinShuLiang + "元");
            } else if (xuHao == 3) {
                System.out.println("请输入你要购买水杯的数量");
                int ShuiBeiShuLiang = scl.nextInt();
                //
                zongJia = zongJia +ShuiBei* ShuiBeiShuLiang;
                System.out.println("你买了水杯" + ShuiBeiShuLiang + "只，需要花费" + ShuiBei * ShuiBeiShuLiang + "元");
            }else if (xuHao == 4) {
                System.out.println("请输入你要购买苹果的数量");
                int pingGuoShuLiang = scl.nextInt();
                //
                zongJia = zongJia +pingGuo* pingGuoShuLiang;
                System.out.println("你买了苹果" + pingGuoShuLiang + "只，需要花费" + ShuiBei *pingGuoShuLiang + "元");
            }else if (xuHao == 5) {
                System.out.println("请输入你要购买香蕉的数量");
                int xiangJiaoShuLiang = scl.nextInt();
                //
                zongJia = zongJia +xiangJiao* xiangJiaoShuLiang;
                System.out.println("你买了香蕉" + xiangJiaoShuLiang + "只，需要花费" + ShuiBei *xiangJiaoShuLiang + "元");
            }
            System.out.println("需要继续购买请输入Y，否则输入N");
            xuanZe = scl.next();
        }
        System.out.println("欢迎下次光临");
        System.out.println("你消费的总金额为"+zongJia);
    }
}
